/*Hdip Project 2013-14, Student Name:- Chris Pembroke,  Student Number:- x00115839*/


    function AddListItem() {
        var itemsSelectedItem = document.getElementById("Items");
        var itemSelected = itemsSelectedItem.options[itemsSelectedItem.selectedIndex].text;

        var actionSelectedItem = document.getElementById("Actions");
        var actionSelected = actionSelectedItem.options[actionSelectedItem.selectedIndex].text;

        var itemaction = actionSelected + " - " + itemSelected;

        var list = document.getElementById("ServiceItems");
        var newListItem = document.createElement('OPTION');
        newListItem.text = itemaction;
        newListItem.value = itemaction;
        list.add(newListItem);

        var allSelectedItems = "";
        
        var list = document.getElementById("ServiceItems");
        for (var i = 0; i < list.options.length; i++) {
            
            allSelectedItems += list.options[i].value + ";\n";
        }
        var textarea = document.getElementById("SelectedItems");
        textarea.value = allSelectedItems;
        
    }

    function RemoveListItem() {

        var list = document.getElementById("ServiceItems");

        if (list.options.length > 0) {

            for (var i = list.options.length - 1; i >= 0; i--) {
                if (list.options[i].selected) {
                    list.remove(i);

                    var allSelectedItems = "";
                    var list = document.getElementById("ServiceItems");
                    for (var i = list.options.length - 1; i >= 0; i--) {
                        allSelectedItems += list.options[i].value + ";\n";
                    }
                    var textarea = document.getElementById("SelectedItems");
                    textarea.value = allSelectedItems;

                    return false;
                }
            }
        }
        else {
            alert("Unable to remove as List Empty");
        }
    }

    $(document).ready(function () {
	    $(function () {
            $('.date-picker').datepicker();
	    });
	 });
	
	